๐Ÿ“š Agora node [[@agora@botsin.space/mac os]] (empty) โ˜†
This Agora node is empty. Be the first to ๐ŸŒฑ Write a contribution, ๐Ÿงญ Wander to a connected node, or ๐ŸŽฎ play a minigame.
๐Ÿ“š Agora node [[20210708160418 macros]] (pulled by the Agora)
๐Ÿ“œ File 20210708160418-macros.org by @ryan โ˜† ๐Ÿ“Ž

Macros are a feature in certain programming languagesthat allow for editing source code at compile or runtime. Similar to functions, macros are a means of code reuse, but rather than rewrite functionality they rewrite code.

Macros first appeared, to my knowledge, in Lisp

In Lisp (specifically Emacs Lisp, a macro looks like this:

(defmacro ++ (var)
  "Incrementing operator like in C."
  (list 'setq var (list '+ 1 var)))

(let ((my-var 1))
  (++ my-var))

2

The above, at runtime, is expanded in the following manner:

(macroexpand '(++ foo))

Consider also the following example in Rust

macro_rules! inc {
    ($name:ident) => {
        $name = $name + 1
    }
}

fn main () {
    let mut foo = 1;
    inc!(foo); // macros in rust end with exclamation points
    println!("foo: {}", foo); // println is also a macro
    // => 2
}

Macros allow for programming language extension

๐Ÿ“š Agora node [[macos]] (pulled by the Agora)
๐Ÿ“œ File macOS.md by @agora@botsin.space โ˜† ๐Ÿ“Ž
๐Ÿ“š Agora node [[macros]] (pulled by the Agora)
๐Ÿ“œ File macros.md by @neil โ˜† ๐Ÿ“Ž ๏ธ๐Ÿ”— โœ๏ธ

macrosยง

๐Ÿ“š Agora node [[vim macros]] (pulled by the Agora)
๐Ÿ“œ File vim macros.md by @agora@botsin.space โ˜† ๐Ÿ“Ž
๐Ÿ“œ File vim macros.md by @an_agora@twitter.com โ˜† ๐Ÿ“Ž
๐Ÿ“œ File vim macros.md by @flaneur@merveilles.town โ˜† ๐Ÿ“Ž